
package com.szu.subject.ui.mq;

import javax.jms.Destination;
import javax.jms.Queue;

import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;

import com.szu.subject.domains.Selection;

@Component
public class SendService {

	@Autowired
	private JmsMessagingTemplate jmsMessagingTemplate;


	public void sendFirst(Selection selection) {
		sendMessage(new ActiveMQQueue("selection.queue.first"), selection);
	}
	
	private void sendMessage(Destination destination, Selection selection) {
		jmsMessagingTemplate.convertAndSend(destination, selection);
	}

	public void sendSecond(Selection selection) {
		sendMessage(new ActiveMQQueue("selection.queue.second"), selection);
	}
	
	public void sendThird(Selection selection) {
		sendMessage(new ActiveMQQueue("selection.queue.third"), selection);
	}
	
}
